package com.cby.assist.Sample;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

/**
 * @description: EnvConfigActivity
 * @author: ChenBaoYang
 * @createDate: 2022/3/7 4:07 下午
 */
public class EnvConfigActivity extends AppCompatActivity {

    private RadioGroup envRg;
    private RadioButton envTestRb;
    private RadioButton envOtRb;
    private RadioButton envOfficialRb;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_env_config);
        envRg = findViewById(R.id.rg_env);
        envTestRb = findViewById(R.id.rb_test);
        envOtRb = findViewById(R.id.rb_ot);
        envOfficialRb = findViewById(R.id.rb_official);

        //表示RadioGroup中的radioButton状态切换时触发的监听
        envRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
                RadioButton rb = (RadioButton)findViewById(checkedId);
                if (checkedId == R.id.rb_test) {
                    //PreferencesUtils.saveEnv(DevToolActivity.this, ToolConstant.ENV_TEST);
                } else if (checkedId == R.id.rb_ot) {
                    //PreferencesUtils.saveEnv(DevToolActivity.this, ToolConstant.ENV_OT);
                } else if (checkedId == R.id.rb_official) {
                    //PreferencesUtils.saveEnv(DevToolActivity.this, ToolConstant.ENV_OFFICIAL);
                }
                String text = rb.getText().toString();
                Toast.makeText(EnvConfigActivity.this, text, Toast.LENGTH_SHORT).show();
            }
        });

    }
}
